#函数
#内置函数-读文件
#判断路径是否存在
import os
print(os.path.exists("D:\\python\\test1\\try\\test.txt"))

#读取文本类型  字节转为字符串
file_object=open('test.txt',mode='rb')
data=file_object.read()
file_object.close()
print(data.decode('utf-8'))
#同等效果
#file_object=open('D:/python/test1/try/test.txt',mode='rt',encoding='utf-8')
#file_object=open(r'D:\python\test1\try\test.txt',mode='rt',encoding='utf-8')
file_object=open('D:\\python\\test1\\try\\test.txt',mode='rt',encoding='utf-8')
data=file_object.read()
file_object.close()
print(data)
#读取图片类型
file_object=open('user.png',mode='rb')
data=file_object.read()
file_object.close()
print(data)